Skip to content

Module.Callback Refactor#2645

Merged
zachdaniel merged 19 commits intoash-project:mainfrom
celeste-wahlquist:main
Mar 27, 2026
Merged

Module.Callback Refactor#2645
zachdaniel merged 19 commits intoash-project:mainfrom
celeste-wahlquist:main

Conversation

@celeste-wahlquist
Copy link
Copy Markdown
Contributor

@celeste-wahlquist celeste-wahlquist commented Mar 23, 2026

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

…h behaviours

- Add Ash.BehaviourHelpers.call_and_validate_return for Notifier, Change, etc.
- Notifier.notify/1 must return :ok
- Change.atomic/3 validates return (e.g. {:not_atomic, String.t()})
- Fix test Notifiers to return :ok; fix test atomic changes to return {:not_atomic, reason}
- Add behaviour_return_validation_test.exs

Made-with: Cursor
Made-with: Cursor
Resolve managed_relationships merge conflicts while preserving M2M error path/index handling.

Made-with: Cursor
Comment thread .github/workflows/ash-ci.yml Outdated
# Only run this job when we're on the main branch, not for PRs
if: github.ref == 'refs/heads/main'
# Only run this job for upstream main (forks often lack dependency submission permissions)
if: github.ref == 'refs/heads/main' && github.repository == 'ash-project/ash'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't add this restriction because many different repositories use this same CI. We'd need to check maybe just the organization, i.e ash-project

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, undid the new 105-106 and left as original

Comment thread test/ash_test.exs

def notify(notification) do
send(self(), {:notification, notification})
:ok
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we weren't requiring this before, I think we should just change the callback to any TBH. Because we've always ignored these results this could break a bunch of people's apps. Alternatively we can add a warn?: true option that will warn on an invalid return and then we can fix it in 4.0 to be more restriction.

Copy link
Copy Markdown
Contributor Author

@celeste-wahlquist celeste-wahlquist Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the callback contract/wrapper to accept any() and removed strict runtime return-shape enforcement there

@callback notify(Ash.Notifier.Notification.t()) :: any()
@SPEC notify(module(), Ash.Notifier.Notification.t()) :: any()

test-subprojects:
runs-on: ubuntu-latest
name: Subproject ${{matrix.project.org}}/${{matrix.project.name}} - OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
if: ${{ github.repository == 'ash-project/ash' || matrix.project.name != 'ash_oban' }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not run this for ash_oban?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this! This isn’t “disable fork CI” wholesale — it only skips the ash_oban subproject matrix job on forks. On ash-project/ash, we still run it. The motivation is that ash_oban’s mix deps.get can pull oban_pro / private Hex packages that forks may not have configured, so the matrix cell would fail for reasons not related to the individuals code. Happy to revisit if we want a different approach 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay. Makes sense.

@zachdaniel
Copy link
Copy Markdown
Contributor

Looks like some conflicts (sorry) and then we can get it merged! Great change 🔥

@zachdaniel zachdaniel merged commit 7b92d6e into ash-project:main Mar 27, 2026
26 of 44 checks passed
@zachdaniel
Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants